package cn.itcast.java.thread;

/**
 * Author itcast
 * Date 2021/10/14 17:02
 * Desc TODO
 */
public class ThreadDemo03 {
    public static void main(String[] args) {
        //匿名内部类创建线程
        new Thread(){
            @Override
            public void run() {
                System.out.println("hello world");
            }
        }.start();
        //实现接口的匿名内部类
        new Runnable(){
            @Override
            public void run() {
                System.out.println("接口的实现匿名内部类");
            }
        }.run();
        //通过匿名内部类包装Thread执行
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("匿名内部类3");
            }
        }).start();
        //lambda表达式实现
        //public abstract void run();
        new Thread(()->{
            System.out.println("lambda表达式实现的匿名内部类");
        }).start();
    }
}
